package com.ruoyi.business.service;

import java.math.BigDecimal;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.bizsys.domain.*;
import com.ruoyi.business.domain.LoanInfo;

/**
 * @Author:
 * @Date: 2021/3/1 10:43 上午
 */
public interface IBLoanInfoService {
	
	public List<LoanInfo> getLoanInfoListByCustNo(String custNo,String loanStatus);
	
	public LoanInfo getLoanInfoListBySerialNo(String custNo, String serialNo);
	
	//根据冲账信息来冲账
	public boolean doLoanRepayment(LoanOffset loanOffset);
	
	//跑批任务获取账户列表
	public List<CreditAccount> getBatchJobOnLoanAccount(String batchDate, int startLimit, int step);
	public List<CreditAccount> getBatchJobOnLoanAccount(String batchDate);

	/**
	 * 查询单个账户信息
	 * @param custNo
	 * @return
	 */
	CreditAccount getOneOnLoanAccountAll(String batchDate,String custNo);

	public int getBatchJobOnLoanAccountNum(String batchDate);
	
	public List<LoanIou> getBatchJobActiveLoanIou(String batchDate, String custNo);
	
	public void doBatchJobByCust(Date batchDate, CreditAccount account);
	
	public void updateAccount(CreditAccount creditAccount);
	
	public boolean doLoanRepaymentGetInfo(LoanOffset loanOffset);
	
	public LoanIou doLoanIouBatchJob(Date batchDate, LoanIou loanIou) throws ParseException;
	
	public RepaymentOrder createRepaymentOrder(LoanIou loan, String bankCardAuthorizationCode, String actionType,BigDecimal withholdRate,String bathNo);
	
	//执行代扣操作
	public boolean doRepaymentAction(String serialNo, CustBankCard custBankCard,String reduceFlag);
	
	public List<CreditAccount> getLoanOffsetFailAccount();
	
	public boolean loanOffset(CreditAccount creditAccount, LoanOffset loanOffset);
	
	//代扣发送结果通知短信
	public void sendRepaidResultSms(RepaymentOrder r);
	
	//做代扣动作
	public Map<String,Boolean> doingRepayment(RepaymentOrder r, String email, String cardNumber);
	
	public RepaymentOrder createRepaymentOrder(LoanIou loan, String bankCardAuthorizationCode, String actionType, BigDecimal repayAmt,BigDecimal withholdRate,String bathNo);

	public RepaymentOrder doCollectionRepaymentAction(LoanIou loanIou, CreditAccount creditAccount, CustBankCard bankCard, BigDecimal repayAmt);

	List<LoanIou> getFirstByCustNo(String accountReference);
	List<LoanIou> getFirstOverdueByCustNo(String accountReference);

	/**
	 * 获取银行信息
	 * @param accountNumber
	 * @return
	 */
    BankCode getBanckInfoByAccountNumber(String accountNumber);

	/**
	 * 最大逾期天数
	 * @param custNo
	 * @return
	 */
	Integer getCurrentOverdue(String custNo);

	/**
	 * 贷款记录排序
	 * @param loanInfoList
	 * @return
	 */
	List<JSONObject> loanInfoListSort(List<JSONObject> loanInfoList);

    List<LoanIou> getBatchJobActiveLoanIouAll(String custNo,Integer minDays,Integer maxDays,Integer subtractDays,Integer surplusDays);

	/**
	 * 是否有Processing，OutStanding的订单
	 * @param custNo
	 * @return
	 */
    boolean isLoanInfoListByInTransit(String custNo);

	Map<String,Boolean> payTransWithholdTrans(RepaymentOrder repaymentOrder, String email);

	RepaymentOrder createRepaymentOrderForDefer(LoanIou loanIou, String authorizationCode, String loanRepaymentOrderTypeOperatedefer, String active,LoanDeferredOrder loanDeferredOrder);

	void doLoanRepaymentGetInfoForDefer(LoanOffset loanOffset);

	/**
	 * 状态成功的repayMentOrder
	 * @param loanIou
	 * @param loanRepaymentOrderTypeOperatedeferWallet
	 * @param active
	 * @param loanDeferredOrder
	 * @param amtWallet
	 * @param walletNo
	 * @return
	 */
	RepaymentOrder createRepaymentOrderForDeferWalletSuccess(LoanIou loanIou, String loanRepaymentOrderTypeOperatedeferWallet, String active,LoanDeferredOrder loanDeferredOrder,BigDecimal amtWallet,String walletNo);

	/**
	 * 状态不成功的repayMentOrder
	 * @param loanIou
	 * @param loanRepaymentOrderTypeOperatedeferWallet
	 * @param active
	 * @param amtWallet
	 * @param walletNo
	 * @return
	 */
	RepaymentOrder createRepaymentOrderForDeferWalletNoSuccess(LoanIou loanIou, String loanRepaymentOrderTypeOperatedeferWallet, String active,LoanDeferredOrder loanDeferredOrder, BigDecimal amtWallet, String walletNo);

	void doLoanRepaymentGetInfoForDeferWalletNotAll(LoanOffset loanOffset);

	void doLoanRepaymentGetInfoForDeferWalletNotAllByPayStsk(LoanOffset loanOffset,LoanOffset loanOffsetWallet);

	RepaymentOrder createRepaymentOrderForDeferForminPay(BigDecimal paystaskAmt, LoanIou loanIou, String authorizationCode, String loanRepaymentOrderTypeOperatedeferWallet, String active, LoanDeferredOrder loanDeferredOrder);

	RepaymentOrder createRepaymentOrderRepayAllWalletNoSuccess(LoanIou loanIou, String loanRepaymentOrderTypeOperatWallet, String active, BigDecimal amtWallet, String walletNo);

	/**
	 * 延期-钱包全额还款
	 * @param loanOffset
	 */
	void doLoanRepaymentGetInfoForDeferWalletAll(LoanOffset loanOffset);
	/**
	 * 非延期-钱包全额还款
	 * @param loanOffset
	 */
	void doLoanRepaymentGetInfoForWalletAll(LoanOffset loanOffset);

	RepaymentOrder createRepaymentOrderForWalletNoSuccess(LoanIou loanIou, String actionType, String active, BigDecimal amtWallet, String walletNo);

	RepaymentOrder createRepaymentOrderForWalletPay(BigDecimal paystaskAmt, LoanIou loanIou, String authorizationCode, String loanRepaymentOrderTypeOperatWallet, String active);

	void doLoanRepaymentGetInfoForWalletNotAll(LoanOffset loanOffsetWallet);

	void doLoanRepaymentGetInfoForWalletNotAllByPayStsk(LoanOffset loanOffset);

	RepaymentOrder createRepaymentOrderForPayNewCard(LoanIou loanIou, String actionType, String active, String payTransSerialNo,BigDecimal amt,LoanDeferredOrder loanDeferredOrder);
	RepaymentOrder createRepaymentOrderForWebhook(LoanIou loanIou, String actionType, String payTransSerialNo,BigDecimal amt,Date payTime,int status);
	void doOverFlowAndWallet(BigDecimal amt, RepaymentOrder repaymentOrder);

}
